package com.github.soiff.shadow.plugin.helper;

import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;

import java.io.IOException;

/**
 * Created by Soiff on 2016/05/20.
 *
 * @author : Soiff
 */
public class GtHelper implements Helper {
    @Override
    public CharSequence apply(Object source, Options options) throws IOException {
        long _source;
        if(source instanceof Long) {
            _source = ((Long)source).longValue();
        } else if(source instanceof Integer) {
            _source = (long)((Integer)source).intValue();
        } else {
            _source = Long.parseLong((String)source);
        }

        return _source > (long)((Integer)options.param(0)).intValue()?options.fn():options.inverse();
    }
}
